using System.Collections.Generic;
using UnityEngine;
using Voodoo.Pattern;

public class BoostConditions : MonoBehaviour
{
	private Progress _progress;

	private Oil _oil => SingletonMB<GameManager>.Instance.currentOilUI;

	private void Start()
	{
		_progress = Object.FindObjectOfType<Progress>();
	}

	public int SuitableBooster()
	{
		int num = (int)_oil.OilValue;
		int num2 = (int)NintendoPlayerPrefs.GetFloat("Money", 0f);
		int num3 = (NintendoPlayerPrefs.GetInt("Power", 0) + NintendoPlayerPrefs.GetInt("Size")) / 25 * 100;
		int @int = NintendoPlayerPrefs.GetInt("Long", 0);
		int num4 = _progress.Pr();
		List<float> list = new List<float> { 0f, 0f, 0f, 0f, 0f };
		if (@int >= 2)
		{
			list[0]++;
		}
		if (num < 40)
		{
			list[0] += 1f;
		}
		else if (num < 10)
		{
			list[0] += 2.1f;
		}
		if (num4 > 40)
		{
			list[0]++;
		}
		if (num3 < 50)
		{
			list[1]++;
		}
		if (num > 10)
		{
			list[1]++;
		}
		if (num2 < 1000)
		{
			list[1]++;
		}
		if (num3 <= 30)
		{
			list[2]++;
		}
		if (num4 <= 30)
		{
			list[2]++;
		}
		if (num3 > 30)
		{
			list[3]++;
		}
		if (num2 < 2000)
		{
			list[3] += 1f;
		}
		if (@int == 3)
		{
			list[3] += 1f;
		}
		if (num <= 13)
		{
			list[4]++;
		}
		if (@int == 3)
		{
			list[4]++;
		}
		if (num3 < 30 || num3 > 70)
		{
			list[4] += 1f;
		}
		if (num4 > 80)
		{
			list[4] += 1f;
		}
		Debug.Log(list[0]);
		Debug.Log(list[1]);
		Debug.Log(list[2]);
		Debug.Log(list[3]);
		Debug.Log(list[4]);
		float num5 = -1f;
		for (int i = 0; i < list.Count; i++)
		{
			if (list[i] > 0f && list[i] > num5)
			{
				num5 = list[i];
			}
		}
		if (num5 == -1f)
		{
			return Random.Range(0, list.Count);
		}
		List<int> list2 = new List<int>();
		for (int j = 0; j < list.Count; j++)
		{
			if (list[j] == num5)
			{
				list2.Add(j);
			}
		}
		return list2[Random.Range(0, list2.Count)];
	}
}
